<template>
  <div class="demo">
    <h3 class="title">学校名称：{{ name }}</h3>
    <h3>学校地址：{{ address }}</h3>
  </div>
</template>

<script>
export default {
  name: 'School',
  data() {
    return {
      name: '尚硅谷atguigu',
      address: '北京',
    }
  },
  mounted() {
    //监听当前实例上自定义事件
    this.$bus.$on('hello',(data)=>{
      console.log('school组件收到了',data)
    })
  },
  beforeDestroy() {
    //解绑事件
    this.$bus.$off('hello')
  }
}
</script>

<style scoped>
.demo {
  background-color: skyblue;
}
</style>
